//package com.yfeng.security.entity;
//
//import org.springframework.security.userdetails.UserDetails;
//import org.springframework.security.GrantedAuthority;
//import org.springframework.security.GrantedAuthorityImpl;
//import org.springframework.security.context.SecurityContextHolder;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * User类
// * User: rqn
// * Date: 2009-2-5
// * Time: 12:04:10
// */
//public class User implements UserDetails {
//
//    private String username, passwd = "";
//    private boolean enable = false;
//    private String[] roles = {""};
//
//    public GrantedAuthority[] getAuthorities() {
//        List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
//        // String[] roles = getRolesByUsername(username);
//        for (int i = 0; i < roles.length; i++) {
//            list.add(new GrantedAuthorityImpl(roles[i]));
//        }
//        return list.toArray(new GrantedAuthority[list.size()]);
//    }
//
//    public String getPassword() {
//        return passwd;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public String getUsername() {
//        return username;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public boolean isAccountNonExpired() {
//        return true;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public boolean isAccountNonLocked() {
//        return true;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public boolean isCredentialsNonExpired() {
//        return true;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public boolean isEnabled() {
//        return enable;  //To change body of implemented methods use File | Settings | File Templates.
//    }
//
//    public void setUsername(String username) {
//        this.username = username;
//    }
//
//    public void setPasswd(String passwd) {
//        this.passwd = passwd;
//    }
//
//    public void setEnable(Boolean enable) {
//        this.enable = enable;
//    }
//
//    public void setRoles(String[] roles) {
//        this.roles = roles;
//    }
//
//    /**
//     * 返回登录后的USER对象
//     *
//     * @return
//     */
//    public static User getCurrentUser() {
//        return (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//    }
//}
